package com.niit.controller;

import java.util.List;

import javax.annotation.Resource;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.data.redis.core.ListOperations;

import org.springframework.data.redis.core.ValueOperations;
import org.springframework.stereotype.Service;

@Service
public class MilkServiceImpl implements MilkService {

    Logger logger = LoggerFactory.getLogger(MilkServiceImpl.class);
   
    @Resource(name="stringRedisTemplate")
    private ValueOperations<String, String> valueOperations;
    @Resource(name="stringRedisTemplate")
    private ListOperations<String, String> listOperations;
	@Override
	public String get(String userToken) {
		// TODO Auto-generated method stub
		
		return valueOperations.get(userToken);
		
	}

	@Override
	public String set(String userToken, String string) {
		// TODO Auto-generated method stub
	
		valueOperations.set(userToken, string);
		
		return "SUCCESS";
	}

	@Override
	public List<String> getCourse(String studentName) {
		// TODO Auto-generated method stub
		
		/*operations.*/
		return listOperations.range(studentName, 0, -1);
		
	}

	@Override
	public String setCourse(String studentName, List<String> courseList) {
		// TODO Auto-generated method stub
		
		/*operations.leftPushAll(studentName, list);*/
		listOperations.leftPushAll(studentName, courseList);
		return "SUCCESS";
	}

}
